<%@ page language="java" contentType="text/html; charset=UTF-8" isELIgnored="false"
    pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>公共池视图</title>
<%@ include file="/base/base.jsp" %>

<style type="text/css">
.btn_a {
	display: block;
	float: left;
	width: 50px;
	height: 20px;
	background: #5CACEE;
	border: 1px solid black;
	cursor: pointer;
	margin-right: 3px;
	color: black;
}

.btn_a:HOVER {
	background: #7EC0EE;
}

input[type='text'] {
	height: 23px;
}

select {
	height: 23px;
}

#result_table,#result_table tr,#result_table td {
	border-color: #D2D2D2;
}
</style>

<script type="text/javascript">
/*
function loadChannels(){
	$.ajax(
			{
				url:url,
				type:"get",
				async: false,
				dataType:"json",
				success:function(data){

				},
			 	error:function(){
			 		alert(msg+",服务器异常，请稍后再试！");
			 		isSuccess = false;
			 	}			
			}
		);
	
}
*/



 var channels = {};
 <s:iterator var="channel" value="vo.channels">
 channels['${channel.key }']='${channel.value}';
 </s:iterator> 
 
//表格列数据
var columns=[
	{display:"序号",width:80,render:function(rowData,rowIndex){
		return (parseInt(this.get("page"))-1)*parseInt(this.get("pageSize"))+rowIndex+1;
	}},
	{display:"IP",width:130,name:"ip"},
	{display:"端口",name:"port",width:130},
	{display:"所属区域",name:"area",width:130},
	{display:"响应时间",name:"responseTime",width:130,render:function(rowData){
		return (rowData.responseTime+" ms");
	}},
	{display:"最后检索时间",name:"retrieveTimeStr",width:130},
	{display:"使用次数",name:"usedCount",width:100},
	{display:"渠道可用",name:"",width:130,render:function(rowData,rowIndex){
		var html = "<font title='" ;
		if(rowData.refuseChannel!=undefined&&rowData.refuseChannel!=null&&rowData.refuseChannel.length!=0){
			var cStr = "";
			var showCell = "";
			for(var code in channels){
				var isExist = false;
				
				for(var i=0;i<rowData.refuseChannel.length;i++){
				
					if(code== rowData.refuseChannel[i]){
						isExist = true;
						break;
					}
				}
				if(!isExist&&'default'!=code){
					showCell = showCell + channels[code] + "  ";
					cStr = cStr + channels[code]+"&#10;";
				}
			}
			if(showCell.length>10){
				showCell = showCell.substring(0,10)+"..";
			}
			html = html+cStr + "'>"+showCell+"</font>";
		}else{
			var cStr = "";
			for(var code in channels){
				if('default'==code){
					continue;
				}
				cStr = cStr + channels[code]+"&#10;";
			}
			html = html+cStr  + "'>所有</font>";
			
		} 
		return html;
	}}
];
$(function(){
	initTime();
	initGrid();
});
//初始化日期时间
function initTime(){
	var now=new Date();
	var year=now.getFullYear();
	var month=now.getMonth()+1;
	month=month<10?"0"+month:month+"";
	var date=now.getDate();
	date=date<10?"0"+date:date+"";
	var start=year+"-"+month+"-"+date+" 00:00:00";
	var hour=now.getHours();
	hour=hour<10?"0"+hour:hour+"";
	var minute=now.getMinutes();
	minute=minute<10?"0"+minute:minute+"";
	var second=now.getSeconds();
	second=second<10?"0"+second:second+"";
	var end=year+"-"+month+"-"+date+" "+hour+":"+minute+":"+hour;
	$("#start_retrieveTimeStr").val(start);
	$("#end_retrieveTimeStr").val(end);
}

function initGrid(){
	var url="<%=request.getContextPath()%>/pools/publicPool/search.action";
	$("#ressult_div").ligerGrid({
			height : '100%',
			width : '100%',
			columns : columns,
			enabledSort : false,
			pageSize : 50,
			root : "result",//数据集合
			record : "dataSize",//总数据数
			pageParmName : "pageIndex",//页索引
			pagesizeParmName : "pageLen",//页长
			usePager : true,
			dataAction : "server",
			onAfterShowData : refreshCount,
			method : "post",
			delayLoad : false,//初始化不加载
			onAfterEdit:"refreshCount",
			pageSizeOptions : [ 20, 50, 100, 200 ],
			url : url
		});
		var manager = $("#ressult_div").ligerGetGridManager();
		manager.set("height", "100%");
	}
	
	function refreshCount(e){
		var total = Number(this.get("total"));
		var threadMaxIpCount = Number('${vo.threadMaxIpCount }');
		var threadCount =  Math.ceil(total/threadMaxIpCount);
		if(threadCount != 0){
		threadCount = total%threadMaxIpCount!=0?threadCount+1:threadCount;
		}else{
			threadCount = 1;
		}
		$("#currNum").html(total);
		$("#threadCount").html(threadCount);
	}
</script>
</head>
<body>

<div class="main main_max" style="height: 100%">
	<div class="form_body">
		<div class="form_body_tltle">
			公共池视图
		</div>
		<form id="realTimeSearch_form">
		    <table  id="result_table" class="form_table">
				<tr style="height:40px; width:100%;">
					<td align="left" width="6%">池大小</td>
					<td align="left" width="6%" id='currNum'>${vo.currNum }</td>
					<td align="left" width="8%">最大使用次数</td>
					<td align="left" width="8%"><font>${vo.ipMaxUsedCount }</font>次</td>
					<td align="left" width="8%">验证间隔时间</td>
					<td align="left" width="8%"><font>${vo.publicIntSeparationTime/1000}</font>秒</td>
					<td align="left" width="8%">检出时间间隔</td>
					<td align="left" width="8%"><font>${vo.publicOutSeparationTime/1000}</font>秒</td>
					<td align="left" width="8%">并发线程数</td>
					<td id='threadCount' align="left">${vo.threadCount }</td>
				    <td align="left" width="8%">最小值</td>
					<td id='threadCount' align="left">${vo.poolProxyMin }</td>
					<td align="left" width="8%">最大值</td>
					<td id='threadCount' align="left">${vo.poolProxyMax }</td>
				</tr>
			</table>
		</form>
	</div>
			<div style="height: 30px"></div>
			<div id="ressult_div" style="height:100%"></div>
	
</div>
</body>
</html>